import time

def format_time(elapsed_time):

    elapsed_time = int(elapsed_time)

    h = elapsed_time // (60 * 60) # 小时
    m = (elapsed_time // 60) % 60  # 分钟
    s = elapsed_time % 60 # 秒

    ret = ''
    if h:
        ret += str(h) + '小时'
    if m:
        ret += str(m) + '分钟'
    if s:
        ret += str(s) + '秒'
    
    return ret



# 计算函数执行时间
def calTime(func):
    def wrapper():
        start_time = time.time()
        func()
        end_time = time.time()
        elapsed_time = end_time - start_time

        print("代码执行时间：", format_time(elapsed_time))

    return wrapper